package com.cunshe.service;

import com.cunshe.dao.SeriesDao;
import com.cunshe.domain.Series;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 产品系列
 * @author xiao
 */
@Service
public class SeriesService {

    @Autowired
    private SeriesDao seriesDao;

    /** 新增 */
    @Transactional(rollbackFor = Exception.class)
    public int insert(Series record) {
        record.setCreatetime(new Date());
        return seriesDao.insert(record);
    }

    /** 删除 */
    @Transactional(rollbackFor = Exception.class)
    public int delete(Long id) {
        return seriesDao.delete(id);
    }

    /** 修改 */
    @Transactional(rollbackFor = Exception.class)
    public int update(Series record) {
        record.setUpdatetime(new Date());
        return seriesDao.update(record);
    }

    /** 查询列表 */
    public List<Series> all() {
        return list(Series.builder().build());
    }

    /** 查询列表 */
    public List<Series> list(Series record) {
        return seriesDao.list(record);
    }

}